package com.yangtzeu.jwc.customview;

import android.app.Dialog;
import android.content.Context;
import android.text.Html;
import android.view.Gravity;
import android.widget.TextView;

import com.zhangdi.jwc.R;

public class CustomeUpdateDialog extends Dialog {
    private Context context = null;
    private static CustomeUpdateDialog customUpdateDialog = null;

    public CustomeUpdateDialog(Context context) {
        super(context);
        this.context = context;
    }

    public CustomeUpdateDialog(Context context, int theme) {
        super(context, theme);
    }

    public static CustomeUpdateDialog createDialog(Context context, String title, android.view.View.OnClickListener listener) {
        customUpdateDialog = new CustomeUpdateDialog(context, R.style.theme_customer_progress_dialog);
        customUpdateDialog.setContentView(R.layout.custom_upload_dialog_layout);
        customUpdateDialog.getWindow().getAttributes().gravity = Gravity.CENTER;
        TextView tv = (TextView) customUpdateDialog.findViewById(R.id.dialog_title);
        tv.setText(title);
        customUpdateDialog.findViewById(R.id.update_cancel).setOnClickListener(listener);
        customUpdateDialog.findViewById(R.id.download_outer).setOnClickListener(listener);
        customUpdateDialog.findViewById(R.id.download_inner).setOnClickListener(listener);
        return customUpdateDialog;
    }

    public void setMsg(String msg) {
        TextView tv = (TextView) findViewById(R.id.msg);
        tv.setText(Html.fromHtml(msg));
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        if (customUpdateDialog == null) {
            return;
        }
    }
}
